@extends('admin._layouts.default')

@section('main')

      <div class="row-fluid ">
        <div class="span12 box gradient ">
      <div class="title">
            <div class="row-fluid">
                <h3>
                  <i class="fa fa-puzzle-piece"></i> 小区管理
                </h3>
            </div>
        </div><!-- End .title -->
        <div class="content min_h500">
          <table id="datatable_city" class="responsive table table-striped table-bordered" style="width:100%;margin-bottom:0; ">
            <thead>
              <tr>
                 <th class="to_hide_phone  no_sort">地址 </th>
                 <th class="to_hide_phone">装机数</th>
                 <th class="to_hide_phone" width="240">水质动态</th>
                 <th class="to_hide_phone">定位状态</th>
                 <th class="to_hide_phone">服务点描述</th>
                <th class="ms no_sort" width="140">操作</th>
                {{--<th class="ms no_sort" width="140">删除</th>--}}
              </tr>
            </thead>
            <tbody>
            @foreach($areas as $area)
              <tr>
                <td class="to_hide_phone">
                    <i class="fa fa-puzzle-piece"></i> <strong>{{ $area->name }}</strong>
                </td>
                <td>
                    <i class="fa fa-wrench"></i> <strong>{{ $area->mount_count }}</strong>
                </td>
                <td >
               <span class="label label-success"><i class="fa fa-ticket"></i> {{ $area->data1 }}</span> <span class="label label-info"><i class="fa fa-flask"></i> {{ $area->data2 }}</span> <small>{{ $area->updated_at }}</small></span>
              </td>
              <td>
              @if($area->cover)
              <img src="http://aebo.qiniudn.com/{{ $area->cover }}-smileth">
              @endif
              @if($area->x > 0 && $area->y > 0)
              | 已定位
              @endif
              </td>
              <td>{{ $area->service_address }}

                  @if($area->service_x > 0 && $area->service_y > 0)
                      | 已定位
                  @endif
                  <a class="btn btn-small" href="{{ route('admin.areas.service_lbs',array('id'=>$area->id)) }}"  rel="tooltip" data-placement="left" data-original-title=" 标注位置 "><i class="fa fa-map-marker"></i></a>

              </td>
                <td class="ms"><div class="btn-group1">
                    <a class="btn btn-small" href="{{ route('admin.areas.lbs',array('id'=>$area->id)) }}"  rel="tooltip" data-placement="left" data-original-title=" 标注位置 "><i class="fa fa-map-marker"></i></a>
                    <a class="btn btn-small" onclick="set_delete('{{ $area->id }}');"  rel="tooltip" data-placement="left" data-original-title=" 新增水质状况 " data-toggle="modal" href="#water_add"><i class="fa fa-tint"></i></a>
                  </div>
                </td>

              </tr>
              @endforeach

            </tbody>
          </table>

                <div class="row-fluid control-group">

                    <div class="pagination pull-right ">
                      <?php echo $areas->links(); ?>
                  </div>
                </div>
                <br/>
        </div><!-- End .content -->
        </div>
        <!-- End box -->
      </div>

@stop


@section('modals')



<div id="water_add" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 class="modal-title" id="myModalLabel">新增本小区水质</h3>
      </div>
      <div class="modal-body">
            {{ Form::open(array('route' => 'admin.areas.store','id'=>'area_form','class'=>'bs-docs-example form-horizontal')) }}
              <input type="hidden" name="area_id" id="delete_id" value="">
              <div class="control-group row-fluid">
                <label class="control-label span4" for="inputPassword">TDS值</label>
                <div class="controls span5 input-append">
                  <input type="text" name="data1" id="inputUsername" class="row-fluid"><span class="add-on"><i class="icon-user"></i></span>
                </div>
              </div>
              <div class="control-group row-fluid">
                <label class="control-label span4" for="inputEmail">TDS值</label>
                <div class="controls span5 input-append">
                  <input type="text" name="data2" id="inputPhone" class="row-fluid"><span class="add-on"><i class="icon-phone"></i></span>
                </div>
              </div>
            </form>


      </div>
      <div class="modal-footer">
                  <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                  <button type="button" onclick="delete_it()" class="btn btn-primary">确定</button>
      </div>
    </div>
  </div>
</div>

<div id="confirm_alert" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 class="modal-title" id="myModalLabel">确定本次操作吗？</h3>
      </div>
      <div class="modal-body">
        <i class=" icon-warning-sign color_red pull-left fs_24"></i>

        <p>一旦【确定】，本次操作不可撤销。</p>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="button" class="btn btn-primary">确定</button>
      </div>
    </div>
  </div>
</div>
@stop


@section('script')
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/full-calendar/fullcalendar.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/jquery.peity.min.js') }}"></script>
<script type="text/javascript" language="javascript" src="{{ URL::asset('ad/js/plugins/datatables/js/jquery.dataTables.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/chosen/chosen/chosen.jquery.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/flot/jquery.flot.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/jquery.uniform.min.js') }}"></script>
<script src="{{ URL::asset('ad/js/plugins/justGage.1.0.1/resources/js/raphael.2.1.0.min.js') }}"></script>
<script src="{{ URL::asset('ad/js/plugins/justGage.1.0.1/resources/js/justgage.1.0.1.min.js') }}"></script>
<script src="{{ URL::asset('ad/js/scripts.js') }}"></script>


    <script type="text/javascript" charset="utf-8">
    // Datatables
    $(document).ready(function() {
      var dontSort = [];
                $('#datatable_city thead th').each( function () {
                    if ( $(this).hasClass( 'no_sort' )) {
                        dontSort.push( { "bSortable": false } );
                    } else {
                        dontSort.push( null );
                    }
      } );
      $('#datatable_city').dataTable( {
        "sDom": "<'row table_top_bar'<'row-fluid'>'<'to_hide_phone'>'f'<'>r>t<'row'>",
         "sDom": "<'row table_top_bar'<'row-fluid'<'to_hide_phone' f>>><'row'>",
         "aaSorting": [[ 1, "asc" ]],
        "bPaginate": false,
        "bJQueryUI": false,
        "aoColumns": dontSort

      } );
      $.extend( $.fn.dataTableExt.oStdClasses, {
        "s`": "dataTables_wrapper form-inline"
      } );
    } );
    </script>
    <script>

    function set_delete(id){
        $('#delete_id').val(id);
    }
    function delete_it(){
        $('#area_form').submit();
    }
    function delete_area(id){
        if(confirm('确定要删除小区吗？删除后无法撤销')){
            window.location.href='/admin/areas/delete?id='+id;
        }
    }
    </script>
@stop
